﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using MyFirstSolution.Model;
using MyFirstSolution.BLL;
namespace MyFirstSolution.UI
{
    public partial class Insert : Form
    {
        public Insert()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            User user = new User(textBox1.Text,textBox2.Text,2);
            DialogResult dr = MessageBox.Show("确认插入" + user.Account + "吗？", "提示", MessageBoxButtons.OKCancel);
            if (dr == DialogResult.OK)
            {
                UserManager userManager = new UserManager();
                if (userManager.InsertUserInfo(user))
                {
                    
                    MessageBox.Show("添加成功！", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else MessageBox.Show("添加失败！", "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
}
